package aptech.lab.servlet.sessionlistener;

import javax.servlet.annotation.WebListener;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

import org.apache.log4j.Logger;

/**
 * Application Lifecycle Listener implementation class SessionLogger
 *
 */
public class SessionLogger implements HttpSessionListener {
	private Logger log;
    /**
     * Default constructor. 
     */
    public SessionLogger() {
    	log = Logger.getLogger(SessionLogger.class);
    }

	/**
     * @see HttpSessionListener#sessionCreated(HttpSessionEvent)
     */
    public void sessionCreated(HttpSessionEvent event) {
    	log.info("HttpSession created: " + event.getSession().getId());
    }

	/**
     * @see HttpSessionListener#sessionDestroyed(HttpSessionEvent)
     */
    public void sessionDestroyed(HttpSessionEvent event) {
    	log.info("HttpSession invalidated: " + event.getSession().getId());
    }
	
}
